#ifndef MYGRAPHICSITEM_H
#define MYGRAPHICSITEM_H

#include <QGraphicsItem>
#include <QColor>
#include <QPainter>
#include <QGraphicsSceneEvent>
#include <QApplication>
#include <QDrag>
#include <QMimeData>

#include <QDebug>

#define LINE_HEIGHT 60


class MyGraphicsItem : public QGraphicsItem
{
public:
    MyGraphicsItem();

    virtual QRectF boundingRect() const;
    virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

    void setLeftHeight(int height);
    void setRightHeight(int height);
    void setTimeLenght(int time);

    int leftHeight() const;
    int rightHeight() const;
    int timeLenght() const;
    int timeLenghtScaled() const;

    void setPos(const qreal x, const qreal y);
    void setPos(const QPointF &point);
    void setXPos(qreal x);
    int nonScaledXPosition(void) const;

    void setScaleX(qreal scale);
    qreal scaleX(void) const;
    void setMyType(QString &type);
    QString myType() const;
    void setColor(QColor &color);
    QColor *color(void) const;

protected:
    virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
    virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
    virtual void mouseDoubleClickEvent ( QGraphicsSceneMouseEvent * event );

private:
    int _leftHeight;
    int _scaledLeftHeight;
    int _rightHeight;
    int _scaledRightHeight;
    int _time;
    int _scaledTime;
    qreal _scale;
    int _xPosition;

    QColor *_color;
    QString _type;

    inline void calculateLeftHeight();
    inline void calculateRightHeight();
    inline void calculateTimeLenght();
    inline void calculateScaledPosition();
};

#include "itemsetdialog.h"

#endif // MYGRAPHICSITEM_H
